<?php echo $this->fetch('header.html'); ?>
<style>
.kdorder_add {background:#f1f1f1;}
.kdorder_add td{padding:6px; background:#FFF; line-height:22px;}
.kdorder_add th {font-size:13px; color:#333; background:#f0f7ff; width:150px; font-weight:normal;text-align:right; padding-right:5px;}
.kdorder_add th em {font-style:normal; color:#F00; margin-right:8px}
.kdorder_add .select_class {border: 1px #d1d1d1 solid;height: 30px;border-radius:2px;width:50%}
.inputBorder{border: 1px #d1d1d1 solid;height: 20px;line-height: 20px;padding:4px 4px; width:50%}
.botton_submit {border:0;background:#ed5736;height:31px;width:100px;text-align:center;line-height:31px;font-family:"Microsoft YaHei";font-size:14px;color:#fff;cursor:pointer;border-radius:4px; margin-right:10px}
</style>
<div id="rightTop">
  <ul class="subnav">
    <li><a class="btn1" href="index.php?app=kd_kehu">合作客户</a></li>
    <li><a class="btn0" href="index.php?app=kd_kehu&act=add">添加客户</a></li>
  </ul>
</div>
<form action="" method="post" id="form_box">
<table width="100%" cellspacing="1" class="kdorder_add">
  <tr><td colspan="2" style="padding:12px 8px;background:#ffffe5">重要提示：入仓号是唯一性的，相同的入仓号则不能录入系统，入仓号码段例如：10010001-10019999。</td></tr>
  <tr>
    <th><em>*</em>合作方代码：</th>
    <td><input type="input" class="inputBorder" name="partner" id="partner" value="<?php echo $this->_var['info']['partner']; ?>" placeholder="请输入合作方代码"/> <font color="#999999">（填写数字或者域名）</font></td>
  </tr>
  <tr>
    <th><em>*</em>合作密钥：</th>
    <td><input type="input" class="inputBorder" name="pass" id="pass" value="<?php echo $this->_var['info']['pass']; ?>" placeholder="请输入合作密钥"/> <font color="#999999">（用于接口调用的唯一密钥）</font></td>
  </tr>  
  <tr>
    <th><em>*</em>入仓号：</th>
    <td><input type="input" class="inputBorder" name="rukuhao1" id="rukuhao1" value="<?php echo $this->_var['info']['rukuhao1']; ?>"  placeholder="最小号段，填写8位数" maxlength="8" style="width:15%" onKeyUp="clearNoNum(this)"/>
        <input type="input" class="inputBorder" name="rukuhao2" id="rukuhao2" value="<?php echo $this->_var['info']['rukuhao2']; ?>"  placeholder="最大号段，填写8位数" maxlength="8" style="width:15%" onKeyUp="clearNoNum(this)"/>
        <font color="#999999">（填写8位数，例如：10010001 - 10019999）</font></td>
  </tr>
  <tr>
    <th><em>*</em>报关码：</th>
    <td><input type="input" class="inputBorder" name="baoguan1" id="baoguan1" value="<?php echo $this->_var['info']['baoguan1']; ?>"  placeholder="最小号段，填写18位数" maxlength="18" style="width:15%" onKeyUp="clearNoNum(this)"/>
        <input type="input" class="inputBorder" name="baoguan2" id="baoguan2" value="<?php echo $this->_var['info']['baoguan2']; ?>"  placeholder="最大号段，填写18位数" maxlength="18" style="width:15%" onKeyUp="clearNoNum(this)"/>
        <font color="#999999">（填写18位数，例如：006940592121000001 - 006940592121000010）</font></td>
  </tr>
  <tr>
    <th><em>*</em>客户姓名：</th>
    <td><input type="input" class="inputBorder" name="lianxiren" id="lianxiren" value="<?php echo $this->_var['info']['lianxiren']; ?>" placeholder="请输入客户姓名"/></td>
  </tr>      
  <tr>
    <th><em>*</em>电话：</th>
    <td><input type="input" class="inputBorder" name="mobilphone" id="mobilphone" value="<?php echo $this->_var['info']['mobilphone']; ?>" placeholder="请输入电话"/></td>
  </tr>
  <tr>
    <th>邮箱：</th>
    <td><input type="input" class="inputBorder" name="Email" id="Email"  value="<?php echo $this->_var['info']['Email']; ?>" placeholder="请输入邮箱"/></td>
  </tr>   
  <tr>
    <th>详细地址：</th>
    <td><input name="address" type="text" id="address" class="inputBorder"  value="<?php echo $this->_var['info']['address']; ?>" placeholder="请输入详细地址"/></td>
  </tr>      
  <tr>
    <th>公司名称：</th>
    <td><input type="input" class="inputBorder" name="company" id="company" value="<?php echo $this->_var['info']['company']; ?>" placeholder="请输入公司名称"/></td>
  </tr>
  <tr>
    <th valign="top" style="padding-top:8px">备注：</th>
    <td><textarea name="notes" id="notes" class="inputBorder" style="height:50px;" placeholder="请输入备注说明"><?php echo $this->_var['info']['notes']; ?></textarea></td>
  </tr>
  <tr>
    <th>状态：</th>
    <td>
    <select name="status" id="status" class="select_class">
    <option value="0" <?php if ($this->_var['info']['status'] == '0'): ?>selected="selected"<?php endif; ?>>合作中</option>
    <option value="1" <?php if ($this->_var['info']['status'] == '1'): ?>selected="selected"<?php endif; ?>>暂停合作（会停止客户调用接口）</option>
    </select>    
    </td>
  </tr>   
  <tr>
    <th>&nbsp;</th>
    <td>
    <input type="button" name="imgButton" class="botton_submit" value="确认提交" onclick="return Check_form();" />
    <input type="reset" class="botton_submit" value="返回上一页" style="background:#999" onclick="javascript:history.back();"/>
    <?php if ($this->_var['info']['kehu_id']): ?>
    <input type="hidden" name="yubao_id"  value="<?php echo $this->_var['order_info']['yubao_id']; ?>"/><input type="hidden" name="act"  value="edit"/>
    <?php else: ?>
    <input type="hidden" name="act"  value="add"/>
    <?php endif; ?>
    </td>
 </tr>
</table>
</form>
<script type="text/javascript">
//sumbit form
function Check_form() {
  var reg = /^[0-9a-zA-Z]+$/;
  if ($("#partner").val() == "" ) { 
     alert("请输入：合作方代码");$("#partner").focus(); return false; 
  }else{
	  if($("#partner").val().length<3){alert("合作方代码不能小于3位");$("#partner").focus(); return false;}
	  if(!reg.test($("#partner").val())){alert("你输入的字符不是数字或者字母");$("#partner").focus(); return false;}
  }
  if ($("#pass").val() == "") { 
     alert("请输入：合作密钥");$("#pass").focus(); return false; 
  }else{
	  if($("#pass").val().length<3){alert("合作密钥不能小于3位");$("#partner").focus(); return false;}
	  if(!reg.test($("#pass").val())){alert("你输入的字符不是数字或者字母");$("#pass").focus(); return false;}
  }  
  if ($("#rukuhao1").val() == "") {alert("请输入：最小入仓号段");$("#rukuhao1").focus(); return false;}
  if ($("#rukuhao2").val() == "") {alert("请输入：最大入仓号段");$("#rukuhao2").focus(); return false;}
  if ($("#baoguan1").val() == "") {alert("请输入：最小报关码号段");$("#baoguan1").focus(); return false;}
  if ($("#baoguan2").val() == "") {alert("请输入：最大报关码号段");$("#baoguan2").focus(); return false;}  
  if ($("#mobilphone").val() == "") {
	  alert("请输入：电话");$("#mobilphone").focus(); return false;
  }else{
	  if(checkTel($("#mobilphone").val()) == false){alert("您输入的电话格式有误，请正确输入");$("#mobilphone").focus(); return false;}
  }
  if($("#Email").val() != "" && (/^(?:\w+\.?)*\w+@(?:\w+\.)*\w+$/.test($("#Email").val())) == false ){
	  alert("您输入的邮箱地址格式有误，请正确输入");$("#Email").focus(); return false; 
  }
  
  $("#form_box").submit();
}
function checkTel(value){
	var isPhone = /^([0-9]{3,4}-)?[0-9]{7,8}$/;
	var isMob=/^((\+?86)|(\(\+86\)))?(13[012356789][0-9]{8}|15[012356789][0-9]{8}|18[02356789][0-9]{8}|147[0-9]{8}|1349[0-9]{7})$/;
	if(isMob.test(value)||isPhone.test(value)){
		return true;
	}else{
		return false;
	}
}
</script>
<?php echo $this->fetch('footer.html'); ?>